{% extends 'oratk_app/master.html' %}
{% block tag_left %}
    {% include 'oratk_app/tag_left_user.html' %}
{% endblock %}
{% block title %}
    <title>ORATK</title>
{% endblock %}
{% block userinfo %}
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <h2 class="page-header">添加监控任务</h2>
        <form class="form-horizontal" action="{{ request.path }}" method="post" >
            <div class="form-group">
                <label class="col-sm-2 control-label">name：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_name" placeholder="名称">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">task：</label>
                <div class="col-sm-3">
                    <select  class="form-control" name="add_tash_info" id="add_tash_info">
                        <option>--</option>
                        {% for i in task_info %}
                            <option>{{ i.name }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">desc：</label>
                <div class="col-sm-3">
                    <input type="text" style="width:300px;" class="form-control" name="add_desc" placeholder="描述">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">crontab_time：</label>
                <div class="col-sm-3">
                    <select  class="form-control" name="add_task_time">
                        <option>--</option>
                        {% for i in task_time %}
                            <option>{{ i.name }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="form-group" id="label_arg_1">
                <label class="col-sm-2 control-label">监控项(参数1)：</label>
                <div class="col-sm-3">
                    <select  class="form-control" name="add_task_point">
                        <option>--</option>
                        {% for i in task_point %}
                            <option>{{ i.name }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
{#            <div class="form-group">#}
{#                <label class="col-sm-2 control-label">limit(参数2)：</label>#}
{#                <div class="col-sm-10">#}
{#                    <input type="text" style="width:300px;" class="form-control" name="add_limit" placeholder="阈值">#}
{#                </div>#}
{#            </div>#}
            <div class="form-group">
                <label class="col-sm-2 control-label">是否启用：</label>
                <div class="col-sm-3">
                    <select  class="form-control" name="add_enable">
                        <option>是</option>
                        <option>否</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_remake" placeholder="备注">
                </div>
            </div>
            <div class="col-sm-10">
                {#                <button type="submit" class="btn ">提交</button>#}
                <div style="text-align:center;vertical-align:middle;"><input type="submit" style="text-align:center;" class="btn" value="提交"></div>
            </div>
        </form>
    </div>
{% endblock %}
{% block script %}
    <script>
        $('#add_tash_info').change(function () {
            var tash_info = $('#add_tash_info').find("option:checked").val()
            if (tash_info == 'cron.tasks.task_args_2') {
                $('#label_arg_2').remove()
                $('#label_arg_1').after(" <div class='form-group' id='label_arg_2'> <label class=\"col-sm-2 control-label\">limit(参数2)：</label><div class=\"col-sm-10\"><input type=\"text\" style=\"width:300px;\" class=\"form-control\" name=\"add_limit\" placeholder=\"阈值\"></div><div>")
            }
            else if (tash_info == 'cron.tasks.add') {
                $('#label_arg_2').remove()
                $('#label_arg_1').after(" <div class='form-group' id='label_arg_2'> <label class=\"col-sm-2 control-label\">limit(参数2)：</label><div class=\"col-sm-10\"><input type=\"text\" style=\"width:300px;\" class=\"form-control\" name=\"add_limit\" placeholder=\"阈值\"></div><div>")
            }
            else {
                $('#label_arg_2').remove()
            }
        })
    </script>
{% endblock %}